﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using FizzWare.NBuilder;

namespace MvcApplication5.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Home/

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult GridOne(int? page)
        {
            var model = new GridOneModel();

            model.TotalCount = 50;
            model.TotalPages = 5;
            model.CurrentPage = page ?? 1;

            model.Load();

            return PartialView("GridOne", model);
        }

    }

    /// <summary>
    /// Paged model
    /// </summary>
    public class GridOneModel : Core.IPagedList<Person>
    {
        public GridOneModel()
        {

        }

        public void Load()
        {
            Data = Builder<Person>
              .CreateListOfSize(5).All().Do(p => p.Name = p.Name + " p: " + CurrentPage)
              .Build().ToList();
        }

        public int TotalCount { get; set; }
        public int TotalPages { get; set; }
        public int CurrentPage { get; set; }

        public IEnumerable<Person> Data
        {
            get;
            set;
        }
    }

    /// <summary>
    /// Entity model
    /// </summary>
    public class Person
    {
        public string Name { get; set; }
        public DateTime DOB { get; set; }
    }
}
